package com.exercises;

import com.exercises.common.ListNode;
import com.exercises.common.TreeNode;

class ExerciseOffer22 {
    public static void main(String[] args) {
        System.out.println(123);
    }

    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode fast = head, slow = head;
        while (fast.next != null && k > 1) {
            fast = fast.next;
            k--;
        }
        while (fast.next != null) {
            fast = fast.next;
            slow = slow.next;
        }
        return slow;
    }


}
